import http from '../..';
import { formatQuery } from '/@/libs/utils/format';

const prefix = '/assembly/tasks';

// /**
//  * 获取覆盖度可选序列表
//  * @param taskId 任务id
//  * @param barcodeId
//  * @returns
//  */
// export const getCoverAvailableSeq = (taskId: string, barcodeId: string) =>
//   http.get(`${prefix}/${taskId}/results/${barcodeId}/bedcov/availableSeqs`);

/**
 * 获取覆盖度图
 * @param taskId 任务id
 * @param barcodeId
 * @param selection 选中序列
 * @returns
 */
export const getCoverChart = (taskId: string, barcodeId: string, selection?: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/bedcov?${formatQuery({ selection })}`);

/**
 * 获取覆盖度图(三代混和组装展示)
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getNanoporeChart = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/nanopore-bedcov`);

/**
 * 获取组装结果列表
 * @param taskId 任务id
 * @param barcodeId
 * @param selection 选中的基因组序列
 * @param width 文本宽度
 * @returns
 */
export const getMedaka = (taskId: string, barcodeId: string, width: number, selection?: string) =>
  http.get(
    `${prefix}/${taskId}/results/${barcodeId}/consensus?${formatQuery({ selection, width })}`,
  );

/**
 * 获取基因组序列可选列表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getMedakaAvailableSeq = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/consensus/availableSeqs`);

/**
 * 获取统计结果表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getReport = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/gc_stat`);

/**
 * 数据统计
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getNanoStats = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/nano-stats`);

/**
 * filtered 数据统计
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getFilteredNanoStats = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/filtered-nano-stat`);

/**
 * 获取耐药和毒力可选type
 * @returns
 */
export const getAbricateType = () => http.get(`${prefix}/params/abricate/types`);

/**
 * 获取耐药和毒力分析表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getAbricateData = (taskId: string, barcodeId: string, type?: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/abricate${type ? '?type=' + type : ''}`);

/**
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getMetagData = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/metag_g`);

/**
 * mlst
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getMlstData = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/mlst`);

/**
 * 获取变异信息表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getMutationInfo = (taskId: string, barcodeId: string) =>
  http.get(`${prefix}/${taskId}/results/${barcodeId}/mutation-info`);
